package com.coolcode.vo;

import com.coolcode.vo.valid.Insert;
import com.coolcode.vo.valid.Update;
import lombok.Data;

import javax.validation.constraints.*;

@Data
public class UserInfoVO {

    /**
     * 主键 id
     */
    @NotNull(groups = Update.class)
    private Integer id;

    /**
     * 用户名
     */
    @NotBlank(groups = Insert.class)
    @Size(groups = {Insert.class, Update.class}, min = 3, max = 10, message = "invalid format")
    private String username;

    /**
     * 密码
     */
    @NotBlank(groups = Insert.class)
    @Size(min = 3, max = 15, message = "invalid format")
    private String password;

    /**
     * 手机号
     */
    @NotBlank(groups = Insert.class)
    @Pattern(regexp = "^1((3[\\d])|(4[5,6,7,9])|(5[0-3,5-9])|(6[5-7])|(7[0-8])|(8[\\d])|(9[1,8,9]))\\d{8}$",message = "invalid format")
    private String telephone;

    /**
     * 邮箱
     */
    @NotBlank(groups = Insert.class)
    @Pattern(regexp = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?" +
            "(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$",message = "invalid format")
    private String email;

}
